package com.soso.base.util.json;

import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

public class DateTimeSerializer implements JsonSerializer<Date> {
    private final static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");   
    
	public final JsonElement serialize(Date srcDate, Type typeOfSrc,
			JsonSerializationContext context) {
		String strDate=sdf.format(srcDate);
		return new JsonPrimitive(strDate);
	}
}